R/sim_dist_spde.R
sim_ays_covar_spde.RdReturns a function to use inside sim_distribution to
generate the error term.
sim_ays_covar_spde(
sd = 2.8,
range = 300,
model = "barrier",
phi_age = 0.5,
phi_year = 0.9,
group_ages = 5:20,
group_years = NULL,
mesh,
barrier.triangles
)Variance (can be age specific)
Decorrelation range
String indicating "barrier" or "spde" to generate Q with
Defines autocorrelation through ages. Can be one value or a vector of the same length as ages.
Defines autocorrelation through years. Can be one value or a vector of the same length as years.
Make space-age-year variance equal across these ages
Make space-age-year variance equal across these years
The mesh used to generate the precision matrix
the set of triangles in the barrier of the mesh for the barrier model
Returns a function for use in sim_distribution.
##SPDE Approach
# \donttest{
## Make a grid
my_grid <- make_grid(res = c(10,10))
## Make a mesh based off it
my_mesh <- make_mesh(my_grid)
sim <- sim_abundance(ages = 1:10, years = 1:10) %>%
sim_distribution(grid = my_grid,
ays_covar = sim_ays_covar_spde(phi_age = 0.8,
phi_year = 0.1,
model = "spde",
mesh = my_mesh),
depth_par = sim_parabola(mu = 200,
sigma = 50))
plot_distribution(sim,ages = 1:5, years = 1:5, type = "heatmap")
## Barrier Approach
sim <- sim_abundance(ages = 1:10, years = 1:10) %>%
sim_distribution(grid = survey_grid,
ays_covar = sim_ays_covar_spde(phi_age = 0.8,
phi_year = 0.1,
model = "barrier",
mesh = survey_lite_mesh$mesh,
barrier.triangles =
survey_lite_mesh$barrier_tri),
depth_par = sim_parabola())
#> Warning: Arbitrary prior values chosen automatically. This may suffice for a first attempt,
#> but should be changed in any serious analysis.
plot_distribution(sim, ages = 1:5, years = 1:5, type = "heatmap")
# }